package cn.easyutil.util.platform.alibaba.alipay;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;

import cn.easyutil.util.javaUtil.JsonUtil;
import cn.easyutil.util.javaUtil.StringUtil;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.domain.AlipayTradeAppPayModel;
import com.alipay.api.internal.util.AlipaySignature;
import com.alipay.api.request.AlipayFundTransOrderQueryRequest;
import com.alipay.api.request.AlipayFundTransToaccountTransferRequest;
import com.alipay.api.request.AlipayTradeAppPayRequest;
import com.alipay.api.request.AlipayTradeQueryRequest;
import com.alipay.api.request.AlipayTradeRefundRequest;
import com.alipay.api.request.AlipayTradeWapPayRequest;
import com.alipay.api.response.AlipayFundTransOrderQueryResponse;
import com.alipay.api.response.AlipayFundTransToaccountTransferResponse;
import com.alipay.api.response.AlipayTradeAppPayResponse;
import com.alipay.api.response.AlipayTradeQueryResponse;
import com.alipay.api.response.AlipayTradeRefundResponse;
import cn.easyutil.util.platform.alibaba.alipay.bean.AliPayBizParamBean;
import cn.easyutil.util.platform.alibaba.alipay.bean.AliPayResultBean;
import cn.easyutil.util.platform.alibaba.alipay.bean.AliPayToAliParamBean;
import cn.easyutil.util.platform.alibaba.alipay.bean.AliRefundParseBean;
import cn.easyutil.util.javaUtil.LoggerUtil;

public class AliPayUtil {

	private String appId;;
	private String privateKey;
	private String publicKey;
	private String callBackPublicKey;
	private String charset = "UTF-8";
	private String signType = "RSA2";
	public AliPayUtil(){}
	public AliPayUtil(String appId,String privateKey,String publicKey){
		this.appId = appId;
		this.privateKey = privateKey;
		this.publicKey = publicKey;
	}
	public AliPayUtil(String appId,String privateKey,String publicKey,String callBackPublicKey){
		this.appId = appId;
		this.privateKey = privateKey;
		this.publicKey = publicKey;
		this.callBackPublicKey = callBackPublicKey;
	}
	
	public String getCallBackPublicKey() {
		return callBackPublicKey;
	}
	public void setCallBackPublicKey(String callBackPublicKey) {
		this.callBackPublicKey = callBackPublicKey;
	}
	public String getAppId() {
		return appId;
	}

	public String getCharset() {
		return charset;
	}
	public void setCharset(String charset) {
		this.charset = charset;
	}
	public String getSignType() {
		return signType;
	}
	public void setSignType(String signType) {
		this.signType = signType;
	}
	public void setAppId(String appId) {
		this.appId = appId;
	}


	public String getPrivateKey() {
		return privateKey;
	}


	public void setPrivateKey(String privateKey) {
		this.privateKey = privateKey;
	}


	public String getPublicKey() {
		return publicKey;
	}


	public void setPublicKey(String publicKey) {
		this.publicKey = publicKey;
	}


	/**
	 * 支付宝H5支付
	 * @param biz
	 * @return
	 */
	public String h5pay(AliPayBizParamBean biz){
		return h5pay(this.appId, this.privateKey, this.publicKey, biz);
	}
	/**
	 * 支付宝h5支付
	 * @param appid	
	 * @param app_private_key	
	 * @param alipay_public_key	
	 * @param charset
	 * @param returnUrl	支付后跳转的页面
	 * @param notifyUrl	支付后异步通知地址
	 * @param out_trade_no	商家订单号
	 * @param total_amount	订单金额(元)
	 * @param body	订单说明
	 * @return	返回form数据给前端
	 */
	public String h5pay(String appId,String privateKey,String publicKey,AliPayBizParamBean biz){
		if(StringUtil.isEmpty(appId) || StringUtil.isEmpty(privateKey)|| StringUtil.isEmpty(publicKey)){
			throw new RuntimeException("支付账户信息缺失");
		}
		if(!biz.check()){
			throw new RuntimeException("支付参数缺失");
		}
		AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", appId, privateKey, "json", this.charset, publicKey, this.signType); //获得初始化的AlipayClient
		AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest();//创建API对应的request
		alipayRequest.setReturnUrl(biz.getReturnUrl());
		alipayRequest.setNotifyUrl(biz.getNotifyUrl());//在公共参数中设置回跳和通知地址
		Map<String,String> param = new HashMap<String, String>();
		param.put("out_trade_no", biz.getOutTradeNo());;
		param.put("total_amount", biz.getTotalAmount()+"");
		param.put("subject", biz.getSubject());
		if(!StringUtil.isEmpty(biz.getBody())){
			param.put("body", biz.getBody());
		}
		if(!StringUtil.isEmpty(biz.getPassbackParams())){
			param.put("passback_params", biz.getPassbackParams());
		}
		param.put("product_code", "QUICK_WAP_PAY");
		alipayRequest.setBizContent(JsonUtil.beanToJson(param));//填充业务参数
		String form="";
		try {
			LoggerUtil.info(this.getClass(), "支付宝H5支付参数:"+JsonUtil.beanToJson(alipayRequest));
			form = alipayClient.pageExecute(alipayRequest).getBody(); //调用SDK生成表单
			LoggerUtil.info(this.getClass(), "支付宝H5支付返回结果:"+form);
			return form;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
	/**
	 * 查询支付宝交易订单
	 * @param out_trade_no	商家订单号(选填)
	 * @param trade_no	支付宝订单号(选填)
	 */
	public String query(String out_trade_no,String trade_no){
		return query(this.appId, this.privateKey, this.publicKey, out_trade_no, trade_no);
	}
	
	/**
	 * 查询支付宝交易订单
	 * @param appid
	 * @param app_private_key
	 * @param alipay_public_key
	 * @param charset
	 * @param out_trade_no	商家订单号(选填)
	 * @param trade_no	支付宝订单号(选填)
	 */
	public String query(String appId,String privateKey,String publicKey,String out_trade_no,String trade_no){
		if(StringUtil.isEmpty(appId) || StringUtil.isEmpty(privateKey)|| StringUtil.isEmpty(publicKey)){
			throw new RuntimeException("支付账户信息缺失");
		}
		AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", appId, privateKey, "json", this.charset, publicKey, this.signType); //获得初始化的AlipayClient
		AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();//创建API对应的request类
		Map<String,String> param = new HashMap<String, String>();
		if(!StringUtil.isEmpty(out_trade_no)){
			param.put("out_trade_no", out_trade_no);
		}
		if(!StringUtil.isEmpty(trade_no)){
			param.put("trade_no", out_trade_no);
		}
		request.setBizContent(JsonUtil.beanToJson(param));//设置业务参数
		try {
			LoggerUtil.info(this.getClass(), "支付宝查询订单信息,参数:"+JsonUtil.beanToJson(request));
			AlipayTradeQueryResponse response = alipayClient.execute(request);//通过alipayClient调用API，获得对应的response类
			LoggerUtil.info(this.getClass(), "支付宝查询订单信息,返回结果:"+response.getBody());
			return response.getBody();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
	/**
	 * 支付宝支付回调数据校验
	 * @param param	支付宝回调时传入的参数
	 * @param publicKey	公钥
	 * @param charset	字符编码(默认utf-8)
	 * @param signType	字符编码(默认RSA2)
	 * @return
	 */
	public AliPayResultBean getCallBackData(Map<String,String> param,String publicKey){

		//需要除去 sign_type 参数 再验签
		param.remove("sign_type");

		if(StringUtil.isEmpty(publicKey)){
			throw new RuntimeException("支付账户信息缺失");
		}
		try {  
	        //调用SDK验证签名
	        boolean signVerified = AlipaySignature.rsaCheckV1(param, publicKey, this.charset,this.signType);
	        if(!signVerified){
	        	LoggerUtil.info(this.getClass(), "支付宝支付回调验签参数:"+param);
	        	LoggerUtil.info(this.getClass(), "支付宝支付回调验签公钥:"+publicKey);
	        	LoggerUtil.info(this.getClass(), "支付宝支付回调验签字符集:"+this.charset);
	        	LoggerUtil.info(this.getClass(), "支付宝支付回调验签加密方法:"+this.signType);
	        	throw new RuntimeException("支付宝签名验证失败");
	        }
	    } catch (Exception e) {
	    	throw new RuntimeException(e); 
	    }
		AliPayResultBean result = new AliPayResultBean();
		//获取需要保存的数据
	    String appId=param.get("app_id");//支付宝分配给开发者的应用Id
	    result.setAppId(appId);
	    String notifyTime=param.get("notify_time");//通知时间:yyyy-MM-dd HH:mm:ss
	    result.setNotifyTime(notifyTime);
	    String gmtCreate=param.get("gmt_create");//交易创建时间:yyyy-MM-dd HH:mm:ss
	    result.setGmtCreate(gmtCreate);
	    String gmtPayment=param.get("gmt_payment");//交易付款时间
	    result.setGmtPayment(gmtPayment);
	    String gmtRefund=param.get("gmt_refund");//交易退款时间
	    result.setGmtRefund(gmtRefund);
	    String gmtClose=param.get("gmt_close");//交易结束时间
	    result.setGmtClose(gmtClose);
	    String tradeNo=param.get("trade_no");//支付宝的交易号
	    result.setTradeNo(tradeNo);
	    String outTradeNo = param.get("out_trade_no");//获取商户之前传给支付宝的订单号（商户系统的唯一订单号）
	    result.setOutTradeNo(outTradeNo);
	    String outBizNo=param.get("out_biz_no");//商户业务号(商户业务ID，主要是退款通知中返回退款申请的流水号)
	    result.setOutBizNo(outBizNo);
	    String buyerLogonId=param.get("buyer_logon_id");//买家支付宝账号
	    result.setBuyerLogonId(buyerLogonId);
	    String sellerId=param.get("seller_id");//卖家支付宝用户号
	    result.setSellerId(sellerId);
	    String sellerEmail=param.get("seller_email");//卖家支付宝账号
	    result.setSellerEmail(sellerEmail);
	    String totalAmount=param.get("total_amount");//订单金额:本次交易支付的订单金额，单位为人民币（元
	    result.setTotalAmount(totalAmount);
	    String receiptAmount=param.get("receipt_amount");//实收金额:商家在交易中实际收到的款项，单位为元
	    result.setReceiptAmount(receiptAmount);
	    String invoiceAmount=param.get("invoice_amount");//开票金额:用户在交易中支付的可开发票的金额
	    result.setInvoiceAmount(invoiceAmount);
	    String buyerPayAmount=param.get("buyer_pay_amount");//付款金额:用户在交易中支付的金额		  
	    result.setBuyerPayAmount(buyerPayAmount);
	    String tradeStatus = param.get("trade_status");// 获取交易状态 
	    result.setTradeStatus(tradeStatus);
	    String passback_params = param.get("passback_params");//支付宝原样返回的拓展字段
	    if(!StringUtil.isEmpty(passback_params)){
	    	result.setPassbackParams(StringUtil.UrlDecode(passback_params));
	    }
	    LoggerUtil.info(this.getClass(), "支付宝支付回调参数封装:"+JsonUtil.beanToJson(result));
	    return result;
	}
	/**
	 * 支付宝支付回调数据校验
	 * @param request	支付宝回调时传入的参数
	 * @param publicKey	公钥
	 * @return
	 */
	public AliPayResultBean getCallBackData(HttpServletRequest request){
		return getCallBackData(request, this.getCallBackPublicKey()==null?this.getPublicKey():this.getCallBackPublicKey());
	}
	/**
	 * 支付宝支付回调数据校验
	 * @param request	支付宝回调时传入的参数
	 * @param publicKey	公钥
	 * @return
	 */
	public AliPayResultBean getCallBackData(HttpServletRequest request,String callBackPublicKey){
		Map<String,String> param = new HashMap<String, String>();
		Enumeration<String> enu = request.getParameterNames();
		while(enu.hasMoreElements()){
			String name = enu.nextElement();
			param.put(name, request.getParameter(name));
		}
		return getCallBackData(param, callBackPublicKey);
	}
	
	/**
	 * 支付宝退款
	 * @param appid
	 * @param app_private_key
	 * @param alipay_public_key
	 * @param charset
	 * @param out_trade_no	商家订单号
	 * @param trade_no	支付宝订单号
	 * @param out_biz_no	支付宝流水号
	 * @param refund_amount	退款金额(元)
	 * @return
	 */
	public AliRefundParseBean refund(String appId,String privateKey,String publicKey,String out_trade_no,String trade_no,String out_biz_no,double refund_amount){
		if(StringUtil.isEmpty(appId) || StringUtil.isEmpty(privateKey)|| StringUtil.isEmpty(publicKey)){
			throw new RuntimeException("支付账户信息缺失");
		}
		AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", appId, privateKey, "json", this.charset, publicKey, this.signType); //获得初始化的AlipayClient
		AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();//创建API对应的request类
		Map<String,String> param = new HashMap<String, String>();
		param.put("out_trade_no", out_trade_no);
		param.put("trade_no", trade_no);
		param.put("out_request_no", out_biz_no);
		param.put("refund_amount", refund_amount+"");
		LoggerUtil.info(this.getClass(),"封装支付宝退款参数:"+JsonUtil.beanToJson(param));
		request.setBizContent(JsonUtil.beanToJson(param));//设置业务参数
		try {
			AlipayTradeRefundResponse response = alipayClient.execute(request);//通过alipayClient调用API，获得对应的response类
			String result = response.getBody();
			AliRefundParseBean fund = JsonUtil.jsonToBean(result, AliRefundParseBean.class);
			if(fund.getCode().equals("10000") && fund.getMsg().equalsIgnoreCase("Success")){
				LoggerUtil.info(this.getClass(),"支付宝退款成功");
				return fund;
			}
			throw new RuntimeException("支付宝退款返回失败:"+result);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	/**
	 * 支付宝退款
	 * @param out_trade_no	商家订单号
	 * @param trade_no	支付宝订单号
	 * @param out_biz_no	支付宝流水号
	 * @param refund_amount	退款金额(元)
	 * @return
	 */
	public AliRefundParseBean refund(String out_trade_no,String trade_no,String out_biz_no,double refund_amount){
		return refund(this.getAppId(), this.getPrivateKey(), this.getPublicKey(), out_trade_no, trade_no, out_biz_no, refund_amount);
	}
	
	/**
	 * app支付
	 * @param param	公共参数
	 * @param returnUrl	支付完成后跳转的页面	
	 * @param notifyUrl	支付结果通知地址
	 * @param out_trade_no	商户系统订单编号
	 * @param total_amount	交易金额（单位：元）
	 * @param body	交易说明
	 * @param passback_params	预留字段，回调中原样返回
	 */
	public String apppay(AliPayBizParamBean biz){
		return apppay(this.appId, this.privateKey, this.publicKey,biz);
	}
	/**
	 * app支付
	 * @param returnUrl	支付完成后跳转的页面	
	 * @param notifyUrl	支付结果通知地址
	 * @param out_trade_no	商户系统订单编号
	 * @param total_amount	交易金额（单位：元）
	 * @param body	交易说明
	 * @param passback_params	预留字段，回调中原样返回
	 */
	public String apppay(String appId,String privateKey,String publicKey,AliPayBizParamBean biz){
		if(StringUtil.isEmpty(appId) || StringUtil.isEmpty(privateKey)|| StringUtil.isEmpty(publicKey)){
			throw new RuntimeException("支付账户信息缺失");
		}
		//实例化客户端
		AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", appId, privateKey, "json", this.charset, publicKey, this.signType);
		//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称：alipay.trade.app.pay
		AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
		//SDK已经封装掉了公共参数，这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
		AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
		if(!StringUtil.isEmpty(biz.getBody())){
			model.setBody(biz.getBody());
		}
		if(!StringUtil.isEmpty(biz.getSubject())){
			model.setSubject(biz.getSubject());
		}
		if(!StringUtil.isEmpty(biz.getOutTradeNo())){
			model.setOutTradeNo(biz.getOutTradeNo());
		}
		if(!StringUtil.isEmpty(biz.getTotalAmount())){
			model.setTotalAmount(biz.getTotalAmount()+"");
		}
		if(!StringUtil.isEmpty(biz.getPassbackParams())){
			model.setPassbackParams(StringUtil.UrlEncode(biz.getPassbackParams()));
		}
		if(!StringUtil.isEmpty(biz.getNotifyUrl())){
			request.setNotifyUrl(biz.getNotifyUrl());
		}
		if(!StringUtil.isEmpty(biz.getReturnUrl())){
			request.setReturnUrl(biz.getReturnUrl());
		}
		model.setProductCode("QUICK_MSECURITY_PAY");
		request.setBizModel(model);
		try {
				LoggerUtil.info(this.getClass(), "支付宝支付参数AlipayTradeAppPayRequest=:"+JsonUtil.beanToJson(request));
		        //这里和普通的接口调用不同，使用的是sdkExecute
		        AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
		        return response.getBody();//就是orderString 可以直接给客户端请求，无需再做处理。
		    } catch (AlipayApiException e) {
		        throw new RuntimeException(e);
		}
	}
	/**
	 * 转账到支付宝	
	 * @param bean	转账到支付宝参数
	 * @return
	 */
	public String payToAli(AliPayToAliParamBean bean){
		return payToAli(this.appId, this.privateKey, this.publicKey, bean);
	}
	/**
	 * 转账到支付宝	
	 * @param appId	
	 * @param privateKey	
	 * @param publicKey	
	 * @param charset	编码格式
	 * @param signType	签名方式
	 * @param bean	转账到支付宝参数
	 * @return
	 */
	public String payToAli(String appId,String privateKey,String publicKey,AliPayToAliParamBean bean){
		if(StringUtil.isEmpty(appId) || StringUtil.isEmpty(privateKey)|| StringUtil.isEmpty(publicKey)){
			throw new RuntimeException("支付账户信息缺失");
		}
		AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",appId,privateKey,"json",this.charset,publicKey,this.signType);
		AlipayFundTransToaccountTransferRequest request = new AlipayFundTransToaccountTransferRequest();
		request.setBizContent(JsonUtil.beanToJson(bean));
		try {
			LoggerUtil.info(this.getClass(), "转账到支付宝,参数:"+JsonUtil.beanToJson(request));
			AlipayFundTransToaccountTransferResponse response = alipayClient.execute(request);
			if(response.isSuccess()){
				LoggerUtil.info(this.getClass(), "转账到支付宝成功");
				return "success";
			}
			throw new RuntimeException("转账到支付宝失败:"+response.getMsg());
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
	/**
	 * 查询转账到支付宝的订单
	 * @param appId
	 * @param privateKey
	 * @param publicKey
	 * @param orderNo	商户自己的订单号
	 */
	public void queryPayToAli(String appId,String privateKey,String publicKey,String orderNo){
		AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",appId,privateKey,"json",this.charset,publicKey,this.signType);
		AlipayFundTransOrderQueryRequest request = new AlipayFundTransOrderQueryRequest();
		Map<String, String> param = new HashMap<String, String>();
		param.put("out_biz_no", orderNo);
		request.setBizContent("{" +
		"\"out_biz_no\":\"3142321423432\"," +
		"\"order_id\":\"20160627110070001502260006780837\"" +
		"  }");
		try {
			AlipayFundTransOrderQueryResponse response = alipayClient.execute(request);
			if(response.isSuccess()){
				System.out.println("调用成功");
			} else {
				System.out.println("调用失败");
			}
		} catch (Exception e) {
		}
	}
	public static void main(String[] args) {
		/** 阿里app_private_key*/
		String ALI_PAY_PRIVATE_KEY = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCfTJahejc6B+vCSW1FdXjgJttpR7SnuqMhmZ/2wB7DdUJ8HTibf39shCYFEbrAAbcXaGW2MxUBEht6CwHlD/6Vz6NmyRkEjCrbmKzLN0SNdz274Fu0UEoKzlPgCLIwEVOBTTzZVuyTXMKocIAK3PoKQwNqoBT+tMjlzC3b/Hk6/RZy5AMe4tIEOG9KhcvA4ACcUlOO7ikH2PUo+YREax4gV75J9flesrNy+AKmFIH3tkz+u6QGJqYUps1PorT4l5bEfSIstyQMRRqxZxmB87QJPj9OpRGvj4ia+Dw+i3iNQgvFrfqzFKUSOI+sfR+0EjsgkWluPPI4XAMqPrE8pkjXAgMBAAECggEACaqzJV9uRIZAh0y/ZcyoJioVfIEOdHM9/Qb+jxG/jCrseu2nBsCo8ePfDsWxqH8yJih+q5zT9Hmt0y0h002yLFMqXk1ryDvdSfAs5DQZY+BNjb4isoGAzMESk/DTJ1mV0K3oOGQu/Q5O/bu9+WrJfZ/tcCYAwCgmXNOUINpkXPDwTAh8bidhW5yFvO2MAtTaZYB+Vabj5o15SkSH+TKIkF882QHaeVGBr8iPvh/mcMFaEkPqcKIwfuqFSd4ZDv2+g16Hhgu8yyR+qj/zxtzF69YvwZlw3p6CEVB1JcLsTdx1Whk9P+BxRbXjp++Tj7dfEJB+my8QJqO4wxgJoJDBQQKBgQDPkia1PpAwFbgU0GG0CQE5eoJAXznCoVp6UmqWhfvJID/ToSHv5FAbkD/sHciokZcCSogBuJqThKy+bSDokozIYfdVc+cZpK32J4nhsb2OU7bgJeZpo0goi2Sq2VKLsilV7WLLOuOEhW7uQR5otcbNulZYiz2h1wxwyBf5/ohM4QKBgQDEd0A0BcxjTM+zBXvlvh90hbjph44xZS68QTsq6bkuEAFv9EoPlQkeVg3shNfh2oRMuVoldDFuWPB0LaqdJSt5R73v9bCja5ATC9ogZP/2KikYfpoQY1jncVIjX2yssVXpoILX2rKx0s/Z0aOfizSGkns7ZEYZfdXB9vzkpi3UtwKBgQCFhwAtkcyRkjcz9IUVmsFV53BI1rlCcifRDpmQsSoyzPMiQcKiHp5FzPrB+rrtbZLWH3n0mXuesDer3GnSEwxLj3HbX87nmR9rfS3eqUdGeqXm9ZqOlEJECr+8hEbspLSgmS/3iq93vZqJ3Awi0eTMzTTkitYf+UYAe0epQ0sNIQKBgQDAiq5dTaF1X/3d0O4PxjhFlhgWpkbwmd0nmjZGZDCbuAvwkFVU2BbLqEKVHcwFCIbIOo7iTfFz164v7eFbiOYGQg0fcoXeYrgcMm1fehxwP/lujASpMvQaPrDlAcwbouAzyp7wtOCT7arOKepVnbOofz5OgoNA0FYBdfF6lHIuGQKBgQC7/64PRe9hCsUWVzVM+jITVQAmwvuFIaYjdoZmvVr1C8jtUyFefkVKmuxV3JFyOt5H2ZI0dqbHjibH45Vwuxaf2yaejTXrltFwGew82ETuH03dhRnBTgu3HPlCm0CRB43ryCVTNdwVp1qwBagFud7ZrKoLrR2cIRXoVHPnHfxYRA==";
		/** 阿里app_public_key*/
		String ALI_PAY_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDI6d306Q8fIfCOaTXyiUeJHkrIvYISRcc73s3vF1ZT7XN8RNPwJxo8pWaJMmvyTn9N4HQ632qJBVHf8sxHi/fEsraprwCtzvzQETrNRwVxLO5jVmRGi60j8Ue1efIlzPXV9je9mkjzOmdssymZkh2QhUrCmZYI/FCEa3/cNMW0QIDAQAB";
		AliPayUtil util = new AliPayUtil("2016122704661078",ALI_PAY_PRIVATE_KEY,ALI_PAY_PUBLIC_KEY);
		util.setSignType("RSA");
		AliPayToAliParamBean param = new AliPayToAliParamBean();
		param.setAmount("1");
		param.setOut_biz_no(UUID.randomUUID().toString().replace("-", ""));
		param.setPayee_account("18606166467");
		param.setPayee_real_name("单鹏冲");
		param.setRemark("明星梦测试");
		util.payToAli(param);
	}
}
